#include<stack>
using namespace std;
class MinStack {
private:
    stack<int> normal_stack;
    stack<int> min_stack;
public:
    MinStack() {

    }

    void push(int val) {
        normal_stack.push(val);
        if (min_stack.empty() || normal_stack.top() <= min_stack.top())
        {
            min_stack.push(val);
        }
    }

    void pop() {
        if (normal_stack.top() == min_stack.top())
        {
            min_stack.pop();
        }
        normal_stack.pop();
    }

    int top() {
        return normal_stack.top();
    }

    int getMin() {
        return min_stack.top();
    }
};